package in.muton.edushare.validators;

import in.muton.edushare.EduShareSession;

import org.apache.wicket.validation.IValidatable;
import org.apache.wicket.validation.validator.AbstractValidator;

import com.edushare.common.dao.UsersDAO;
import com.edushare.common.vo.Users;

public class AuthenticationValidator extends AbstractValidator {

	private static final long serialVersionUID = 1446590205480060128L;

	private Users user;
	
	
	public AuthenticationValidator(String username, String password) {
		super();
		EduShareSession session = EduShareSession.get();
		this.user = new UsersDAO(session.getSessionORMInterface()).getAuthenticUser(username, password);
	}

	
	@Override
	protected void onValidate(IValidatable validateMe) {
		if(this.user==null){
			error(validateMe);
		}
	}

}
